﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using OutdoorLib.BaseEntity.Dictionary;

public partial class iFarmeDictionary_AdressPrograms : System.Web.UI.Page
{
    /// <summary>
    /// Справочник адресных программ
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Page_Load(object sender, EventArgs e)
    {
        

        if (!IsPostBack)
            MyBind();
    }

    protected string GetEditCommand(string ID)
    {
        string s = "iFrameDictionary_TreeDictionaryEditor.aspx?ID=" + ID ;        
        return "Redirect('" + AppEnvironment.PageNavigator.GetUrlCommand(s) + "');";
        
    }

    private void MyBind()
    {
        lvProgramList.DataSource = AddressDictionaryList;
        lvProgramList.DataBind();
    }
    protected void OnAdd_Click(object sender, EventArgs e)
    {
        TreeDictionaryItem d=AppEnvironment.DictionarySource.CreateTreeDictionaryItem(TreeDictionaryItem.TreeDictionary_AdressProgram);            
        Response.Redirect (AppEnvironment.PageNavigator.GetUrlCommand("iFrameDictionary_TreeDictionaryEditor.aspx?ID="+d.ID));
    }
    public TreeDictionaryItem[] AddressDictionaryList
    {
        get 
        {
            TreeDictionaryItem[]  res =AppEnvironment.DictionarySource.GetTreeDictionaryList(TreeDictionaryItem.TreeDictionary_AdressProgram);
            var result =
                from i in res
                orderby i.Name
                select i;
            return result.ToArray<TreeDictionaryItem>();
        }
    }

}
